import request from '@/utils/request';

export async function getErrorReportFileInfoByPage(params: any) {
  return request('/api/product/getErrorReportFileInfoByPage', {
    method: 'POST',
    data: params,
  });
}

export async function addErrorReportFileInfo(params: any) {
  return request('/api/product/addErrorReportFileInfo', {
    method: 'POST',
    data: params,
  });
}

export async function updateErrorReportFileInfo(params: any) {
  return request('/api/product/updateErrorReportFileInfo', {
    method: 'POST',
    data: params,
  });
}

export async function delErrorReportFileInfo(params: any) {
  return request('/api/product/delErrorReportFileInfo', {
    method: 'POST',
    data: params,
  });
}

export async function exportErrorReportFileInfo(params: any) {
  return request('/api/product/exportErrorReportFileInfo', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}
export async function getErrorReportFileInfoPageByErrorReportId(params: any) {
  return request('/api/product/getErrorReportFileInfoPageByErrorReportId', {
    method: 'POST',
    data: params,
  });
}
export async function getErrorPreviewUrl(para: any) {
  return request('/api/product/getErrorPreviewUrl', {
    method: 'POST',
    params: {
      errorReportFileInfoId: para.id,
    },
  });
}
//异常处理新增附件
export async function uploadErrorReportFileInfo(para: any) {
  return request('/api/product/uploadErrorReportFileInfo', {
    method: 'POST',
    requestType: 'form',
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    data: para.file,
    params: {
      errorReportId: para.errorReportId,
    },
  });
}
export default {
  getErrorReportFileInfoByPage,
  addErrorReportFileInfo,
  updateErrorReportFileInfo,
  delErrorReportFileInfo,
  exportErrorReportFileInfo,
  getErrorReportFileInfoPageByErrorReportId,
  getErrorPreviewUrl,
  uploadErrorReportFileInfo,
};
